package com.share.bean.oa.org;

import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.share.bean.sysmgr.privilege.PrivilegeResource;
import com.share.bean.sysmgr.privilege.PrivilegeRole;
import com.share.commons.enumeration.Gender;

/**
 * 说明：员工PO
 * <br/>编写者：杨浩泉
 * <br/>日期：2010-3-1
 */
@Entity
@Table(name="share_oa_employee")
public class Employee {

	/** 员工编号 */
	private String empNo ;
	
	/** 员工名称 */
	private String empRealname ;
	
	/** 应聘部门 */
	private String acceptDept ;
	
	/** 应聘职位 */
	private String acceptJob ;
	
	/** 民族 */
	private String nation ;
	
	/** 性别 */
	private Gender gender = Gender.MAN ;
	
	/** 出生年月日 ,采用只含有日期部分的类型表示 */
	private Date birthday;
	
	/** 毕业学校 */
	private String school ;
	
	/** 文化程度 */
	private String educational ;
	
	/** 专业 */
	private String speciality ;
	
	/** 工作年限 */
	private int ageJob ;
	
	/** 籍贯 */
	private String natives ;
	
	/** 户口所在地 */
	private String residence ;
	
	/** 现居住地址 */
	private String residentialAddr ;
	
	/** 联系电话 */
	private String tel ;

	/** 移动电话 */
	private String mobileTel ;

	/** 电子邮件 */
	private String email ;
	
	/** 紧急联系人 */
	private String emergency ; 
	
	/** 紧急联系人电话 */
	private String emergencyTel ; 
	
	/** 员工图片 */
	private String empImage ;

	/** 入职日期 */
	private Date appointmentDate ;
	
	/** 员工添加日期 */
	private Date empCreDate ;

	/** 员工在职状态 true为在职,false为离职 */
	private boolean visible = true ;
	
	/** 员工登录账号密码信息 */
	private EmpAccount empAccount ; 
	
	/** 身份证、社保号、银行账号 */
	private EmpCard empCard ;
	
	/** 离职日期、离职原因 */
	private EmpDimission dimissionMsg ;
	
	/** 员工与部门多对一关联，维护端为员工 */
	private Department department ;
	
	/** 员工与角色多对多 */
	private Set<PrivilegeRole> role ;
	
	/** 员工与受保护资源多对多 */
	private Set<PrivilegeResource> resource ;

	@ManyToMany(fetch=FetchType.LAZY)
	@JoinTable(name="share_privilege_emp_res",
				joinColumns={@JoinColumn(name="emp_id")},
				inverseJoinColumns={@JoinColumn(name="res_id")})
	public Set<PrivilegeResource> getResource() {
		return resource;
	}

	public void setResource(Set<PrivilegeResource> resource) {
		this.resource = resource;
	}

	@ManyToMany(fetch=FetchType.LAZY)
	@JoinTable(name="share_privilege_emp_role",
				joinColumns={@JoinColumn(name="emp_id")},
				inverseJoinColumns={@JoinColumn(name="role_id")})
	public Set<PrivilegeRole> getRole() {
		return role;
	}

	public void setRole(Set<PrivilegeRole> role) {
		this.role = role;
	}

	@Temporal(TemporalType.DATE)
	public Date getEmpCreDate() {
		return empCreDate;
	}

	public void setEmpCreDate(Date empCreDate) {
		this.empCreDate = empCreDate;
	}

	public String getAcceptDept() {
		return acceptDept;
	}

	public String getAcceptJob() {
		return acceptJob;
	}
	
	public int getAgeJob() {
		return ageJob;
	}
	
	@Temporal(TemporalType.DATE)
	public Date getAppointmentDate() {
		return appointmentDate;
	}

	@Temporal(TemporalType.DATE)
	public Date getBirthday() {
		return birthday;
	}

	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="dept_id")
	public Department getDepartment() {
		return department;
	}

	@OneToOne(cascade=CascadeType.ALL,fetch=FetchType.LAZY)
	@JoinColumn(name="dimis_id")
	public EmpDimission getDimissionMsg() {
		return dimissionMsg;
	}

	public String getEducational() {
		return educational;
	}

	public String getEmail() {
		return email;
	}

	public String getEmergency() {
		return emergency;
	}

	public String getEmergencyTel() {
		return emergencyTel;
	}

	@OneToOne(cascade=CascadeType.ALL,fetch=FetchType.LAZY)
	@JoinColumn(name="account_id")
	public EmpAccount getEmpAccount() {
		return empAccount;
	}

	@OneToOne(cascade=CascadeType.ALL,fetch=FetchType.LAZY)
	@JoinColumn(name="card_id")
	public EmpCard getEmpCard() {
		return empCard;
	}

	public String getEmpImage() {
		return empImage;
	}

	@Id @Column(length=12,nullable=false)
	public String getEmpNo() {
		return empNo;
	}

	public String getEmpRealname() {
		return empRealname;
	}

	@Enumerated(EnumType.STRING)
	public Gender getGender() {
		return gender;
	}

	public String getMobileTel() {
		return mobileTel;
	}

	public String getNation() {
		return nation;
	}

	public String getNatives() {
		return natives;
	}

	public String getResidence() {
		return residence;
	}

	public String getResidentialAddr() {
		return residentialAddr;
	}

	public String getSchool() {
		return school;
	}

	public String getSpeciality() {
		return speciality;
	}

	public String getTel() {
		return tel;
	}

	public boolean isVisible() {
		return visible;
	}

	public void setAcceptDept(String acceptDept) {
		this.acceptDept = acceptDept;
	}

	public void setAcceptJob(String acceptJob) {
		this.acceptJob = acceptJob;
	}

	public void setAgeJob(int ageJob) {
		this.ageJob = ageJob;
	}

	public void setAppointmentDate(Date appointmentDate) {
		this.appointmentDate = appointmentDate;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	public void setDepartment(Department department) {
		this.department = department;
	}

	public void setDimissionMsg(EmpDimission dimissionMsg) {
		this.dimissionMsg = dimissionMsg;
	}

	public void setEducational(String educational) {
		this.educational = educational;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public void setEmergency(String emergency) {
		this.emergency = emergency;
	}

	public void setEmergencyTel(String emergencyTel) {
		this.emergencyTel = emergencyTel;
	}

	public void setEmpAccount(EmpAccount empAccount) {
		this.empAccount = empAccount;
	}

	public void setEmpCard(EmpCard empCard) {
		this.empCard = empCard;
	}

	public void setEmpImage(String empImage) {
		this.empImage = empImage;
	}
	
	public void setEmpNo(String empNo) {
		this.empNo = empNo;
	}

	public void setEmpRealname(String empRealname) {
		this.empRealname = empRealname;
	}

	public void setGender(Gender gender) {
		this.gender = gender;
	}

	public void setMobileTel(String mobileTel) {
		this.mobileTel = mobileTel;
	}

	public void setNation(String nation) {
		this.nation = nation;
	}

	public void setNatives(String natives) {
		this.natives = natives;
	}

	public void setResidence(String residence) {
		this.residence = residence;
	}

	public void setResidentialAddr(String residentialAddr) {
		this.residentialAddr = residentialAddr;
	}

	public void setSchool(String school) {
		this.school = school;
	}

	public void setSpeciality(String speciality) {
		this.speciality = speciality;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

	public void setVisible(boolean visible) {
		this.visible = visible;
	}
	
}
